<app-editor [(ngModel)]="data" (ngModelChange)="basicForm.patchValue($event)" [submitting]="submitting" (submit)="submit()">

  <nz-collapse [formGroup]="basicForm" (change)="change()">
    <nz-collapse-panel nzHeader="基本信息" nzActive>
      <nz-form-item>
        <nz-form-label [nzSpan]="5">名称</nz-form-label>
        <nz-form-control [nzSpan]="12" nzErrorTip="">
          <input nz-input formControlName="name" required/>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label [nzSpan]="5">模板</nz-form-label>
        <nz-form-control [nzSpan]="12" nzErrorTip="">
          <app-choose-template formControlName="template_id" [showClear]="true"></app-choose-template>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item *ngIf="!basicForm.value.template_id">
        <nz-form-label [nzSpan]="5">组态</nz-form-label>
        <nz-form-control [nzSpan]="12" nzErrorTip="">
          <app-choose-hmi formControlName="hmi" [showClear]="true"></app-choose-hmi>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label [nzSpan]="5">禁用</nz-form-label>
        <nz-form-control [nzSpan]="12" nzErrorTip="">
          <nz-switch formControlName="disabled"></nz-switch>
        </nz-form-control>
      </nz-form-item>
    </nz-collapse-panel>

    <nz-collapse-panel nzHeader="绑定设备" nzActive>
      <app-edit-devices formControlName="devices"></app-edit-devices>
    </nz-collapse-panel>

    <ng-container *ngIf="!basicForm.value.template_id">

      <nz-collapse-panel nzHeader="数据检查" nzActive>
        <app-edit-alarms formControlName="alarms"></app-edit-alarms>
      </nz-collapse-panel>

      <nz-collapse-panel nzHeader="定时任务" nzActive>
        <app-edit-jobs formControlName="jobs"></app-edit-jobs>
      </nz-collapse-panel>

      <nz-collapse-panel nzHeader="控制策略" nzActive>
        <app-edit-strategies formControlName="strategies"></app-edit-strategies>
      </nz-collapse-panel>

      <nz-collapse-panel nzHeader="聚合计算" nzActive>
        <app-edit-aggregators formControlName="aggregators"></app-edit-aggregators>
      </nz-collapse-panel>
    </ng-container>


  </nz-collapse>


</app-editor>
